gpio.mode(4,gpio.OUTPUT)
gpio.write(4,gpio.LOW)
wifi.setmode(wifi.SOFTAP)
wifi.ap.config({ssid="nodeMCU", pwd="12345678", auth=wifi.WPA2_PSK})

print("start")
print("ap ip:"..wifi.ap.getip())
print("ap mac:"..wifi.ap.getmac())




-- Serving static files
dofile("httpServer.lua")
dofile("pwm.lua")
led_init(1000,500);
httpServer:listen(80)

-- Custom API
-- Get text/html
httpServer:use('/PWM_post', function(req, res)
	req.method="get"
	if req.query.Data1~=nil  then
	a={	req.query.Data1,
		req.query.Data2,
		req.query.Data3,
		req.query.Data4,
		req.query.Data5,
		req.query.Data6}
	for	i=1,6 do 
		print(a[i])
		led_set(i,a[i])
		end
	end
	res:send('Data is finished!')
	
end)--从服务器得到数据
httpServer:use('/PWM_get', function(req, res)
	req.method="get"
	local a={pwm.getduty(1),pwm.getduty(2),pwm.getduty(3),pwm.getduty(4),pwm.getduty(5),pwm.getduty(6)}

	res:type('application/json')
		res:send(cjson.encode(a))
	
end)--从服务器得到数据
httpServer:use('/net_get', function(req, res)
	req.method="get"
	net_ssid=req.query.SSID
	net_pwd =req.query.PWD
	if net_ssid ~= nil and net_pwd ~=nil then
	


	
	end
	res:type('application/json')
		res:send(cjson.encode(netip))
	
end)--从服务器得到数据
